package inet.db.tennis.servlet;

import inet.db.tennis.TennisPlayerDAO;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

import java.math.BigDecimal;

/* Lớp này dùng để hiện ảnh 
 * trên trang jsp
 * */
public class TennisPlayerServlet extends HttpServlet {
  
    public void init() throws ServletException {
    }

    public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    	String sId = (String)req.getParameter("id");
        String sType = (String)req.getParameter("t");
        if(sType == null && "".equals(sType)){
        	sType = "0"; // wap content
        }
        if (sId == null || "".equals(sId)) {
            res.setContentType("text/plain");
            return;
        }
        sId = sId.trim();
        TennisPlayerDAO playerDAO = new TennisPlayerDAO();  
        javax.servlet.ServletOutputStream out = res.getOutputStream();
        try {
            byte[] contentGif = null; 
            contentGif = playerDAO.getAvatar(new BigDecimal(sId));
            out.write(contentGif, 0, contentGif.length);
            out.flush();
            out.close();
        } catch (Exception ex) {
            //System.out.println("ForumAnimationServlet[Forum.bongda.wap.vn]"+ex.getMessage());
        }
    }

    //Process the HTTP Post request
    public void doPost(HttpServletRequest req, HttpServletResponse res) throws
        ServletException, IOException {
        doGet(req, res);
    }

    //Clean up resources
    public void destroy() {
    }
}
